﻿using CoreWeb;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class CoreWebServiceCollectionExtensions
    {
        public static IApplicationBuilder UseAutoImg(
            this IApplicationBuilder builder)
        {
            return builder.UseMiddleware<AutoImgMiddleware>();
        }
        public static void AddAutoImg(this IServiceCollection services)
        {
            services.AddSingleton<AutoImgMiddleware>();
        }


        public static IApplicationBuilder UseThumbnail(
           this IApplicationBuilder builder, Action<ThumbnailOptions> options)
        {
            var middleware = builder.ApplicationServices.GetService<ThumbnailMiddleware>();
            options(middleware.Options);
            return builder.UseMiddleware<ThumbnailMiddleware>();
        }
        public static void AddThumbnail(this IServiceCollection services)
        {
            services.AddSingleton(new ThumbnailMiddleware());
        }
    }
}
